{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# while Loop "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# while loops are used for itretating thorugh the particular Conditions is not met true "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey i am - 1\n",
      "Hey i am - 2\n",
      "Hey i am - 3\n",
      "Hey i am - 4\n",
      "Hey i am - 5\n",
      "Hey i am - 6\n",
      "Hey i am - 7\n",
      "Hey i am - 8\n",
      "Hey i am - 9\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i<10:\n",
    "    print(\"Hey i am -\", i)\n",
    "    i = i+ 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Even Number -  2\n",
      "Even Number -  4\n",
      "Even Number -  6\n",
      "Even Number -  8\n",
      "Even Number -  10\n",
      "Even Number -  12\n",
      "Even Number -  14\n",
      "Even Number -  16\n",
      "Even Number -  18\n",
      "Even Number -  20\n",
      "Even Number -  22\n",
      "Even Number -  24\n",
      "Even Number -  26\n",
      "Even Number -  28\n",
      "Even Number -  30\n",
      "Even Number -  32\n",
      "Even Number -  34\n",
      "Even Number -  36\n",
      "Even Number -  38\n",
      "Even Number -  40\n",
      "Even Number -  42\n",
      "Even Number -  44\n",
      "Even Number -  46\n",
      "Even Number -  48\n",
      "Even Number -  50\n",
      "Even Number -  52\n",
      "Even Number -  54\n",
      "Even Number -  56\n",
      "Even Number -  58\n",
      "Even Number -  60\n",
      "Even Number -  62\n",
      "Even Number -  64\n",
      "Even Number -  66\n",
      "Even Number -  68\n",
      "Even Number -  70\n",
      "Even Number -  72\n",
      "Even Number -  74\n",
      "Even Number -  76\n",
      "Even Number -  78\n",
      "Even Number -  80\n",
      "Even Number -  82\n",
      "Even Number -  84\n",
      "Even Number -  86\n",
      "Even Number -  88\n",
      "Even Number -  90\n",
      "Even Number -  92\n",
      "Even Number -  94\n",
      "Even Number -  96\n",
      "Even Number -  98\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "\n",
    "while i < 100:\n",
    "    if i%2==0:\n",
    "        print(\"Even Number - \", i)\n",
    "    i = i +1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Break, Pass & Continue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Object `used` not found.\n"
     ]
    }
   ],
   "source": [
    "# Break - \n",
    "\n",
    "#Where is BREAK Keyword used?\n",
    "\n",
    "#Break is used for breaking a particular loop "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter the input Yes or NO (y/n)-f\n",
      "KEep on asking for holiday\n",
      "Enter the input Yes or NO (y/n)-n\n",
      "KEep on asking for holiday\n",
      "Enter the input Yes or NO (y/n)-n\n",
      "KEep on asking for holiday\n",
      "Enter the input Yes or NO (y/n)-n\n",
      "KEep on asking for holiday\n",
      "Enter the input Yes or NO (y/n)-n\n",
      "KEep on asking for holiday\n",
      "Enter the input Yes or NO (y/n)-n\n",
      "KEep on asking for holiday\n",
      "Enter the input Yes or NO (y/n)-n\n",
      "KEep on asking for holiday\n",
      "Enter the input Yes or NO (y/n)-y\n",
      "KEep on asking for holiday\n",
      "Done approved \n"
     ]
    }
   ],
   "source": [
    "char = \"n\"\n",
    "\n",
    "char.lower()\n",
    "\n",
    "while char.lower() != 'y':\n",
    "    char = input(\"Enter the input Yes or NO (y/n)-\")\n",
    "    print(\"KEep on asking for holiday\")\n",
    "else:\n",
    "    print(\"Done approved \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "#break is used for breaking the loop \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for i in range(1,10):\n",
    "    print(i)\n",
    "    if i== 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "HEY I AM SAI And teaching u guys python \n",
      "2\n",
      "HEY I AM SAI And teaching u guys python \n",
      "3\n",
      "HEY I AM SAI And teaching u guys python \n",
      "4\n",
      "HEY I AM SAI And teaching u guys python \n",
      "5\n",
      "6\n",
      "HEY I AM SAI And teaching u guys python \n",
      "7\n",
      "HEY I AM SAI And teaching u guys python \n",
      "8\n",
      "HEY I AM SAI And teaching u guys python \n",
      "9\n",
      "HEY I AM SAI And teaching u guys python \n"
     ]
    }
   ],
   "source": [
    "# Continue - is used for skipping the closed Loop \n",
    "for i in range(1,10):\n",
    "    print(i)\n",
    "    if i== 5:\n",
    "        continue\n",
    "    print(\"HEY I AM SAI And teaching u guys python \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "# pass: Does nothing at all nd is been used as placeholder \n",
    "\n",
    "i = 10 \n",
    "\n",
    "for i in range(100):\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# File Handling ?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a File, Open that File and Write to that file \n",
    "file = open(\"letsupgrade.txt\",\"w\")\n",
    "file.write(\"Hey Guys I Hope you will meet me on Monday\")\n",
    "file.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey Guys I Hope you will meet me on Monday\n"
     ]
    }
   ],
   "source": [
    "# Read fromt the File we created \n",
    "\n",
    "file = open(\"letsupgrade.txt\",\"r\")\n",
    "fileData = file.read()\n",
    "print(fileData)\n",
    "file.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Lets Append data to the File \n",
    "\n",
    "file = open(\"letsupgrade.txt\",\"a\")\n",
    "file.write(\"\\nRate today class as compared to rest out of 5\")\n",
    "file.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "# For reading and writing together we use r+\n",
    "file = open(\"letsupgrade.txt\",\"r+\")\n",
    "file.write(\"Hey Guys !!!\")\n",
    "file.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
